+Tue Mar 2 16:18:43 2004 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_reorder)
+ * gtk/gtkliststore.c (gtk_list_store_reorder): Fix
+ up the interpretation of new_order to match what
+ it means elsewhere, document the meaning of new_order.
+
+ * gtk/gtkcombobox.c (gtk_combo_box_model_rows_reordered):
+ Fix interpretation of new_order.
+
+ * tests/testcombochange.c (on_reorder): Fix interpretation
+ of new_order.
+
+ * tests/testcombochange.c (on_reorder): Fix hitting
+ "reorder" with an empty list.
+
Tue Mar 2 21:23:30 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Patch from Frederic Crozat, test code from Jean-Philippe
+Tue Mar 2 16:18:43 2004 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_reorder)
+ * gtk/gtkliststore.c (gtk_list_store_reorder): Fix
+ up the interpretation of new_order to match what
+ it means elsewhere, document the meaning of new_order.
+
+ * gtk/gtkcombobox.c (gtk_combo_box_model_rows_reordered):
+ Fix interpretation of new_order.
+
+ * tests/testcombochange.c (on_reorder): Fix interpretation
+ of new_order.
+
+ * tests/testcombochange.c (on_reorder): Fix hitting
+ "reorder" with an empty list.
+
Tue Mar 2 21:23:30 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Patch from Frederic Crozat, test code from Jean-Philippe
+Tue Mar 2 16:18:43 2004 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_reorder)
+ * gtk/gtkliststore.c (gtk_list_store_reorder): Fix
+ up the interpretation of new_order to match what
+ it means elsewhere, document the meaning of new_order.
+
+ * gtk/gtkcombobox.c (gtk_combo_box_model_rows_reordered):
+ Fix interpretation of new_order.
+
+ * tests/testcombochange.c (on_reorder): Fix interpretation
+ of new_order.
+
+ * tests/testcombochange.c (on_reorder): Fix hitting
+ "reorder" with an empty list.
+
Tue Mar 2 21:23:30 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Patch from Frederic Crozat, test code from Jean-Philippe
+Tue Mar 2 16:18:43 2004 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_reorder)
+ * gtk/gtkliststore.c (gtk_list_store_reorder): Fix
+ up the interpretation of new_order to match what
+ it means elsewhere, document the meaning of new_order.
+
+ * gtk/gtkcombobox.c (gtk_combo_box_model_rows_reordered):
+ Fix interpretation of new_order.
+
+ * tests/testcombochange.c (on_reorder): Fix interpretation
+ of new_order.
+
+ * tests/testcombochange.c (on_reorder): Fix hitting
+ "reorder" with an empty list.
+
Tue Mar 2 21:23:30 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Patch from Frederic Crozat, test code from Jean-Philippe
+Tue Mar 2 16:18:43 2004 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_reorder)
+ * gtk/gtkliststore.c (gtk_list_store_reorder): Fix
+ up the interpretation of new_order to match what
+ it means elsewhere, document the meaning of new_order.
+
+ * gtk/gtkcombobox.c (gtk_combo_box_model_rows_reordered):
+ Fix interpretation of new_order.
+
+ * tests/testcombochange.c (on_reorder): Fix interpretation
+ of new_order.
+
+ * tests/testcombochange.c (on_reorder): Fix hitting
+ "reorder" with an empty list.
+
Tue Mar 2 21:23:30 2004 Soeren Sandmann <sandmann@daimi.au.dk>
Patch from Frederic Crozat, test code from Jean-Philippe
gint items = gtk_tree_model_iter_n_children (model, NULL);
gint i;
- combo_box->priv->active_item = new_order[combo_box->priv->active_item];
+ for (i = 0; i < items; i++)
+ if (new_order[i] == combo_box->priv->active_item)
+ {
+ combo_box->priv->active_item = i;
+ break;
+ }
if (!combo_box->priv->tree_view)
gtk_combo_box_menu_rows_reordered (model, path, iter, new_order, user_data);
-
}
static void
/**
* gtk_list_store_reorder:
* @store: A #GtkListStore.
- * @new_order: An integer array indicating the new order for the list.
+ * @new_order: an array of integers mapping the new position of each child
+ * to its old position before the re-ordering,
+ * i.e. @new_order<literal>[newpos] = oldpos</literal>.
*
* Reorders @store to follow the order indicated by @new_order. Note that
* this function only works with unsorted stores.
for (i = 0; i < store->length; i++)
{
- sort_array[i].offset = new_order[i];
+ sort_array[new_order[i]].offset = i;
sort_array[i].el = current_list;
current_list = current_list->next;
* gtk_tree_store_reorder:
* @tree_store: A #GtkTreeStore.
* @parent: A #GtkTreeIter.
- * @new_order: An integer array indication the new order for the list.
+ * @new_order: an array of integers mapping the new position of each child
+ * to its old position before the re-ordering,
+ * i.e. @new_order<literal>[newpos] = oldpos</literal>.
*
* Reorders the children of @parent in @tree_store to follow the order
* indicated by @new_order. Note that this function only works with
node = level;
for (i = 0; i < length; i++)
{
- sort_array[i].offset = new_order[i];
+ sort_array[new_order[i]].offset = i;
sort_array[i].node = node;
node = node->next;
static void
on_reorder (void)
{
- GArray *new_contents = g_array_new (FALSE, FALSE, sizeof (char));
- gint *shuffle_array = g_new (int, contents->len);
- gint *shuffle_array_inverse = g_new (int, contents->len);
+ GArray *new_contents;
+ gint *shuffle_array;
gint i;
+ shuffle_array = g_new (int, contents->len);
+
for (i = 0; i < contents->len; i++)
shuffle_array[i] = i;
gtk_list_store_reorder (model, shuffle_array);
- for (i = 0; i < contents->len; i++)
- shuffle_array_inverse[shuffle_array[i]] = i;
-
+ new_contents = g_array_new (FALSE, FALSE, sizeof (char));
for (i = 0; i < contents->len; i++)
g_array_append_val (new_contents,
- g_array_index (contents, char, shuffle_array_inverse[i]));
+ g_array_index (contents, char, shuffle_array[i]));
g_array_free (contents, TRUE);
contents = new_contents;
log ("Reordered array");
g_free (shuffle_array);
- g_free (shuffle_array_inverse);
}
int